<template>
	<view>
		<view class="top">
			<view class="bgbox">
				<!-- <image class="bg" src="/static/img/my/topbg.png" mode=""></image> -->
			</view>
			<view class="" style="position: absolute;width: 750rpx;height: 444rpx;">
				<u-navbar title="我的" leftIcon=' ' titleStyle='color:#fff;font-size:36rpx;' bgColor='transparent'>
				</u-navbar>
				<view class="perinfo flex">
					<view class="flex">
						<image class="avatar" :src="userInfo.avatar" mode=""></image>
						<view class="info">
							<view class="name">
								{{ userInfo.nickname }}
							</view>
							<view class="infoid">
								ID:{{ userInfo.id }}
							</view>
							<view class="code flex">
								邀请码:{{userInfo.invite}}
								<view class="copy" @click="copy">
									复制
								</view>
							</view>
						</view>
					</view>
					<view class="edit_btn flex" @click="goto('/pages/my/userinfo')">
						<image class="edit_icon" src="/static/img/my/edit.png" mode=""></image>
						编辑
					</view>
				</view>
			</view>
			<view class="xiansbox flex">
				<view class="xsitem" @click="goto('/pages/tongzhi/tz')">
					<view class="item_num">
						{{userInfo.pass}}
					</view>
					<view class="item_name">
						惠积分
					</view>
				</view>
				<view class="item_line">

				</view>
				<view class="xsitem" @click="goto('/pages/tongzhi/tongzhi')">
					<!-- pages/tongzhi/tongzhi -->
					<view class="item_num">
						{{userInfo.score_two}}
					</view>
					<view class="item_name">
						贡献值
					</view>
				</view>
				<view class="item_line">

				</view>
				<view class="xsitem" @click="goto('/pages/tongz/tongz')">
					<view class="item_num">
						{{userInfo.score }}
					</view>
					<view class="item_name">
						惠值积分
					</view>
				</view>
			</view>
		</view>
		<view class="title flex">
			<view class="title_name">
				我的订单
			</view>
			<view class="more" @click="goto('/pages/order/myorder')">
				全部订单
				<image class="right_icon" src="/static/img/my/right.png" mode=""></image>
			</view>
		</view>
		<view class="" style="margin-bottom: 70rpx;">
			<u-grid :border="false" col='4'>
				<u-grid-item v-for="(baseListItem,baseListIndex) in baseList" :key="baseListIndex"
					@click="clickto(baseListItem)">
					<image :src="baseListItem.name" style="margin-top: 54rpx;width: 43rpx;height: 43rpx;" mode="">
					</image>
					<text class="grid-text">{{baseListItem.title}}</text>
				</u-grid-item>
			</u-grid>
		</view>
		<view class="title flex">
			<view class="title_name">
				必备工具
			</view>
		</view>
		<view class="" style="">
			<u-grid :border="false" col='4'>
				<u-grid-item v-for="(baseListItem,baseListIndex) in baseList1" :key="baseListIndex"
					v-if="baseListItem.ishow" @click="clickto(baseListItem)">
					<image :src="baseListItem.name" style="margin-top: 54rpx;width: 43rpx;height: 43rpx;" mode="">
					</image>
					<text class="grid-text">{{baseListItem.title}}</text>
				</u-grid-item>
			</u-grid>
		</view>
	</view>
</template>

<script>
	import {
		userInfo
	} from '@/api/my.js'
	export default {
		data() {
			return {
				baseList: [{
						name: '/static/img/my/tab1.png',
						title: '待付款',
						url: '/pages/order/myorder?status=0'
					},
					{
						name: '/static/img/my/tab2.png',
						title: '待发货',
						url: '/pages/order/myorder?status=1'
					},
					{
						name: '/static/img/my/tab3.png',
						title: '待收货',
						url: '/pages/order/myorder?status=2'
					},
					{
						name: '/static/img/my/tab4.png',
						title: '已完成',
						url: '/pages/order/myorder?status=3'
					},
				],
				baseList1: [{
						name: '/static/img/my/tab11.png',
						title: '邀请好友',
						url: '/pages/friend/list',
					},
					{
						name: '/static/img/my/tab12.png',
						title: '消费记录',
						url: '/pages/my/wallet'
					},
					{
						name: '/static/img/my/tab13.png',
						title: '入驻商家',
						url: '/pages/my/settle'
					},
					{
						name: '/static/img/my/tab13.png',
						title: '商家管理',
						url: '/pages/business/management',
					},
					{
						name: '/static/img/my/tab14.png',
						title: '商家升级',
						url: '/pages/my/upgrade'
					},
					{
						name: '/static/img/my/tab14.png',
						title: '服务中心',
						url: '/pages/service/service'
					},
					{
						name: '/static/img/my/tab15.png',
						title: '数据统计',
						url: '/pages/my/statistics'
					},
					{
						name: '/static/img/my/tab16.png',
						title: '个人签到',
						url: '/pages/my/sign'
					},
					{
						name: '/static/img/my/tab17.png',
						title: '合伙人',
						url: '/pages/my/partner'
					},
					{
						name: '/static/img/my/tab18.png',
						title: '客服中心',
						url: '/pages/my/customer'
					},
				],
				userInfo: {}
			};
		},
		methods: {

			clickto(item) {
				if (item.title == '服务中心') {
					// uni.$u.route(item.url,{is_server:item.is_server});
					uni.navigateTo({
						url: item.url + '?is_server=' + this.userInfo.server_status
					})
					return
				}
				if (item.title == '合伙人') {
					// uni.$u.route(item.url,{is_server:item.is_server});
					uni.navigateTo({
						url: item.url + '?is_preson=' + this.userInfo.person_status
					})
					return
				}
				if(item.title == '入驻商家'){
					uni.navigateTo({
						url: item.url + '?is_merchant=' + this.userInfo.merchant_submit_status
					})
					return
				}
				uni.$u.route(item.url, {
					from: 'mine'
				});
			},
			goto(url) {
				uni.$u.route(url, {
					from: 'mine'
				});
			},
			copy(){
				uni.setClipboardData({
					data: this.userInfo.invite,
					success: function () {
						// console.log('success');	
						uni.showToast({
							title:'已复制',
							icon:'none'
						})
					}
				});
			},
			getUserInfo() {
				userInfo().then(res => {
					this.userInfo = res.data.data
					uni.setStorageSync('userinfo', this.userInfo)
					// console.log(this.userInfo.is_merchant)
					if (this.userInfo.merchant_submit_status== '已通过') { ///pages/business/management
					// 入驻
						this.baseList1[2].ishow=false
					} else {
					// 管理
						this.baseList1[3].ishow=false
					}
					// console.log(this.baseList1)
				})
			}
		},
		onShow() {
			this.baseList1.map(t => {
				t.ishow = true
			})
			this.getUserInfo()
		}
	}
</script>

<style lang="less">
	.top {
		width: 750rpx;
		height: 444rpx;
		position: relative;
		margin-bottom: 113rpx;

		.bg {
			width: 2034rpx;
			height: 604rpx;
			position: absolute;
			top: calc(40% - 302rpx);
			left: calc(50% - 1017rpx);
		}

		.top_title {
			padding-top: 50rpx;
			text-align: center;
			font-size: 36rpx;
			color: #fff;
		}

		.perinfo {
			width: calc(750rpx - 35rpx - 31rpx);
			justify-content: space-between;
			padding: 0 35rpx 0 31rpx;
			position: absolute;
			bottom: 132rpx;

			.avatar {
				width: 134rpx;
				height: 134rpx;
				border-radius: 50%;
				border: 8rpx solid #fd874c;
			}

			.info {
				color: #fff;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				margin-left: 14rpx;
				height: 150rpx;

				.name {
					font-size: 32rpx;
					font-weight: bold;
					margin-top: 15rpx;
				}

				.infoid {
					font-size: 30rpx;
				}

				.code {
					font-size: 24rpx;
					margin-bottom: 24rpx;

					.copy {
						line-height: 28rpx;
						border: 1rpx solid #FFFFFF;
						border-radius: 14rpx;
						padding: 0 10rpx;
						margin-left: 16rpx;
					}
				}
			}

			.edit_btn {
				line-height: 52rpx;
				background: linear-gradient(119deg, #FFD22B, #FFA304);
				border-radius: 26rpx;
				padding: 0 18rpx;
				font-size: 26rpx;
				color: #fff;

				.edit_icon {
					width: 26rpx;
					height: 26rpx;
					margin-right: 7rpx;
				}
			}
		}
	}

	.xiansbox {
		position: absolute;
		bottom: -94rpx;
		width: calc(692rpx - 166rpx);
		height: 157rpx;
		box-shadow: 0px 0px 43rpx 0px rgba(83, 28, 0, 0.15);
		background-color: #fff;
		border-radius: 20rpx;
		justify-content: space-between;
		padding: 0 83rpx;
		left: 30rpx;

		.xsitem {
			text-align: center;

			.item_num {
				font-size: 36rpx;
				color: #333;
				font-weight: bold;
				margin-bottom: 10rpx;
			}

			.item_name {
				color: #969696;
				font-size: 24rpx;
			}
		}

		.item_line {
			width: 2rpx;
			height: 40rpx;
			background: #EAEAEA;
		}
	}

	.title {
		justify-content: space-between;
		padding: 0 32rpx;
		margin-top: 50rpx;

		.title_name {
			font-size: 32rpx;
			color: #333;
			font-weight: bold;
		}

		.more {
			font-size: 24rpx;
			color: #999999;

			.right_icon {
				width: 13rpx;
				height: 21rpx;
				margin-left: 8rpx;
			}
		}
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.grid-text {
		font-size: 26rpx;
		color: #333;
		margin-top: 20rpx;
	}

	.bgbox {
		width: 750rpx;
		overflow: hidden;
		position: absolute;
		height: 444rpx;
		background-color: #fb6013;
	}
</style>
